//
//  ZhuangCheMainNavBar.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2021/4/13.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "ZhuangCheMainNavBar.h"

@interface ZhuangCheMainNavBar ()

@property (nonatomic, strong) UIButton *backBtn;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIButton *yiChangBtn;
@property (nonatomic, strong) UIButton *yiJianBtn;

@end

@implementation ZhuangCheMainNavBar

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = HexColor(0xffffff);
        
        self.backBtn = [[UIButton alloc] initWithFrame:CGRectMake(15, StatusBarHeight+(NaviHeight - StatusBarHeight - 24) * 0.5, 24, 24)];
        [self.backBtn setImage:[UIImage imageNamed:@"nav_back"] forState:0];
        [self.backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.backBtn];
        
        self.titleLab = [[UILabel alloc] initWithFrame:CGRectMake(self.backBtn.nim_right + 15, self.backBtn.nim_top + 2.5, 80, 19)];
        self.titleLab.textColor = HexColor(0x000000);
        self.titleLab.font = BoldFontOfSize(18);
        [self addSubview:self.titleLab];
        
        self.yiJianBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenW - 15 - 88, StatusBarHeight + 7, 88, 30)];
        [self.yiJianBtn setTitle:@"一键装车" forState:0];
        [self.yiJianBtn setTitleColor:HexColor(0xffffff) forState:0];
        self.yiJianBtn.titleLabel.font = BoldFontOfSize(14);
        self.yiJianBtn.layer.masksToBounds = YES;
        self.yiJianBtn.layer.cornerRadius = 16;
        self.yiJianBtn.backgroundColor = Color_ThemeColor;
        [self.yiJianBtn addTarget:self action:@selector(yiJianZhuangCheClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.yiJianBtn];
        
        self.yiChangBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.yiJianBtn.nim_left - 10 - 88, self.yiJianBtn.nim_top, 88, 30)];
        [self.yiChangBtn setTitle:@"状态上报" forState:0];
        [self.yiChangBtn setTitleColor:HexColor(0xF35959) forState:0];
        self.yiChangBtn.titleLabel.font = BoldFontOfSize(14);
        self.yiChangBtn.layer.masksToBounds = YES;
        self.yiChangBtn.layer.cornerRadius = 16;
        self.yiChangBtn.backgroundColor = HexColorA(0xF35959, 0.1);
        [self.yiChangBtn addTarget:self action:@selector(yiChangShangBaoClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.yiChangBtn];
    }
    return self;
}

-(void)setTitleStr:(NSString *)titleStr {
    _titleStr = titleStr;
    self.titleLab.text = titleStr;
}

- (void)backClick {
    if (self.backBlock) {
        self.backBlock();
    }
}

- (void)yiJianZhuangCheClick {
    if (self.yiJianBlock) {
        self.yiJianBlock();
    }
}

- (void)yiChangShangBaoClick {
    if (self.yiChangBlock) {
        self.yiChangBlock();
    }
}

@end
